import { Controller, Get, Param ,UseGuards,Request} from '@nestjs/common';
import { UserCourseService } from './course.service';
import { AuthGuard } from '../../guards/auth.guard';
import { User, userType } from "../user.decorators";


@Controller('user-course')
export class userCourseController {
  constructor(private readonly courseService: UserCourseService) {}
  @Get('')
  @UseGuards(AuthGuard)
  getCourseList(@User() user:userType) {
    return this.courseService.getCourseList(user.userId);
  }

  @Get(':id')
  @UseGuards(AuthGuard)
  getCourseDetail(@User() user:userType,@Param('id') id: string) {
    return this.courseService.getCourseDetail(user.userId,id);
  }
  @UseGuards(AuthGuard)
  @Get('get-course-id/:courseId')
  getUserOpenCourse(
    @User() user: userType,
    @Param("courseId") courseId: string
  ) {
    return this.courseService.getUserOpenCourse(user.userId,courseId);
  }
  @UseGuards(AuthGuard)
  @Get('open-course/:courseId')
  userOpenCurse(
    @User() user: userType,
    @Param("courseId") courseId: string
  ) {
    return this.courseService.submitOpenCourse(user.userId,courseId);
  }
  
}
